package mse.eai.jbpm.registerBetProcess;

import java.util.HashMap;
import java.util.Map;

import org.jboss.logging.Logger;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

public class PrepareESBVarsMakeAccountMovement implements ActionHandler {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8139733257179749771L;
	private static final Logger log = Logger
			.getLogger(PrepareESBVarsMakeAccountMovement.class);

	public void execute(ExecutionContext context) throws Exception {

		log.info("Executing ---------->");
		
		try {
			
			Integer uid = (Integer)context.getVariable("uid");
			Integer gameId = (Integer)context.getVariable("gameId");
			Integer amount = (Integer)context.getVariable("amount");
			Integer bet = (Integer)context.getVariable("bet");
			
			Map toBankMap = new HashMap();
			toBankMap.put("uid", uid);
			toBankMap.put("amount", amount);
			
			context.setVariable("toESB", toBankMap);
			
			log.info("Set in context: " + "toESB  = " + toBankMap);
			
			context.leaveNode(); 

		} catch (Exception ex) {
			log.error("Exception: ", ex);
			log.error("ProcessInstance will be suspended");
			context.getProcessInstance().suspend();
		}
		
		log.info("<--------------- Done");

	}

}